package com.morn.fanfou.fragment;

import com.morn.fanfou.R;
import com.morn.fanfou.StatusListActivity;
import com.morn.fanfou.TrendsListActivity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

public class SearchFragment extends Fragment implements OnClickListener {
	private View searchView;
	private View lookaroundView;
	private View hotwordsView;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.search, container, false);
		TextView titleText = (TextView) v.findViewById(R.id.header_title_text);
		titleText.setText(R.string.header_title_search);

		ImageView leftImage = (ImageView) v
				.findViewById(R.id.header_image_left);
		leftImage.setVisibility(View.GONE);

		ImageView rightImage = (ImageView) v
				.findViewById(R.id.header_image_right);
		rightImage.setVisibility(View.GONE);

		searchView = v.findViewById(R.id.search_);
		searchView.setOnClickListener(this);

		lookaroundView = v.findViewById(R.id.search_layout_lookaround);
		lookaroundView.setOnClickListener(this);

		hotwordsView = v.findViewById(R.id.search_layout_hotwords);
		hotwordsView.setOnClickListener(this);

		return v;
	}

	@Override
	public void onClick(View v) {
		if (v == searchView) {
			getActivity().onSearchRequested();
		} else if (v == lookaroundView) {
			Intent intent = new Intent(this.getActivity(),
					StatusListActivity.class);
			intent.putExtra("statusType",
					StatusListFragment.TYPE_STATUS_LOOKAROUND);
			startActivity(intent);
		} else if (v == hotwordsView) {
			Intent intent = new Intent(this.getActivity(),
					TrendsListActivity.class);
			startActivity(intent);
		}

	}
}
